import { defineStore } from "pinia";
import { computed, shallowRef } from "vue";
import { ApiDictionary } from "../../api";

export const useDictionaryStore = defineStore("dictionary", () => {
  const list = shallowRef<UI.Dictionary[]>();
  const staffCategoryList = computed(() => {
    return list.value?.filter(
      (item) => item.dic_group_key === "staff_category"
    );
  });
  const classMajorList = computed(() =>list.value?.filter((item) => item.dic_group_key === "class_major"));
  const quslificationList=computed(()=>{return list.value?.filter(item=>item.dic_group_key==="qualification")})

  ApiDictionary.get().then((data) => {
    list.value = data;
  });
  return { list, staffCategoryList, classMajorList ,quslificationList};
});
